package net.sk.china.front.service.impl.shipping;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sk.china.common.model.shipping.ShippingTemplatesFree;
import net.sk.china.front.dao.shipping.ShippingTemplatesFreeDao;
import net.sk.china.front.service.shipping.ShippingTemplatesFreeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ShippingTemplatesServiceImpl 接口实现
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/12 22:06
 * +----------------------------------------------------------------------
 */
@Service
public class ShippingTemplatesFreeServiceImpl extends ServiceImpl<ShippingTemplatesFreeDao, ShippingTemplatesFree> implements ShippingTemplatesFreeService {

    @Resource
    private ShippingTemplatesFreeDao dao;


    /**
     * 根据模板编号、城市ID查询
     * @param tempId 模板编号
     * @param cityId 城市ID
     * @return {@code ShippingTemplatesFree}
     */
    @Override
    public ShippingTemplatesFree getByTempIdAndCityId(Integer tempId, Integer cityId) {
        LambdaQueryWrapper<ShippingTemplatesFree> query = new LambdaQueryWrapper<>();
        query.eq(ShippingTemplatesFree::getTempId, tempId).eq(ShippingTemplatesFree::getCityId, cityId).eq(ShippingTemplatesFree::getStatus, true);
        query.orderByDesc(ShippingTemplatesFree::getId);
        query.last("limit 1");

        return dao.selectOne(query);
    }
}
